package com.personalsystem.login.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Component;

import com.personalsystem.common.bean.NavigationTree;
import com.personalsystem.login.bean.PersonalInfo;
import com.personalsystem.login.dao.LoginDao;
import com.personalsystem.tool.hibernate.BaseDaoImpl;


@Component("loginDao")
public class LoginImpl extends BaseDaoImpl<PersonalInfo> implements LoginDao{
	
	public void insert(){
		PersonalInfo info=new PersonalInfo();
		info.setUsername("xieyaxiong");
		info.setPassword("scott");
		Session session=sessionFactory.getCurrentSession();
		session.save(info);
	}

	public List<NavigationTree> loadTree(long id) {
		Session session=sessionFactory.getCurrentSession();
		Query query=session.createQuery("from NavigationTree t where t.uplink=?");
		query.setParameter(0, id);
		List<NavigationTree> treeList=(List<NavigationTree>)query.list();
		return treeList;
		
	}

	public void insertB() {
		// TODO Auto-generated method stub
		PersonalInfo info=new PersonalInfo();
		info.setUsername("xieyaxiong");
		info.setPassword("scott");
		Session session=sessionFactory.getCurrentSession();
		session.save(info);
	}

}
